package com.example.thinkpad.androiddemo2;

import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;

import com.example.thinkpad.androiddemo2.Apater.TestAdapter;
import com.example.thinkpad.androiddemo2.Model.StudentModel;

import java.util.ArrayList;
import java.util.List;

/**
 * @author wangchangzheng
 */
public class MainActivity extends AppCompatActivity {
    private RecyclerView rcvTest;
    private List<StudentModel> models = new ArrayList<>();
    private TestAdapter adapter;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        rcvTest =  findViewById(R.id.rcv_test);

        for (int i = 0; i < 5; i++) {
            StudentModel model = new StudentModel("哈哈哈" + i, 10 + i);
            models.add(model);
        }

        rcvTest.setLayoutManager(new LinearLayoutManager(this));
        adapter = new TestAdapter(R.layout.item_student_info, models);
        rcvTest.setAdapter(adapter);
    }
}
